package com.ge.modules.sys.controller;

import com.ge.common.utils.PageUtils;
import com.ge.common.utils.Query;
import com.ge.common.utils.R;
import com.ge.modules.entity.TbRechargeOrderEntity;
import com.ge.modules.sys.service.SysRechargeOrderService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * 充值订单表
 *
 * @author lanyonglin
 * @email www.baidu.com
 * @date 2018-08-07 14:42:16
 */
@RestController
@RequestMapping("/sys/rechargeorder")
public class SysRechargeOrderController {
    @Autowired
    private SysRechargeOrderService rechargeOrderService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("rechargeorder:list")
    public R list(@RequestParam Map<String, Object> params) {
        //查询列表数据
        Query query = new Query(params);

        List<TbRechargeOrderEntity> rechargeOrderList = rechargeOrderService.queryList(query);
        int total = rechargeOrderService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(rechargeOrderList, total, query.getLimit(), query.getPage());

        return R.ok().put("page", pageUtil);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("rechargeorder:info")
    public R info(@PathVariable("id") Integer id) {
        TbRechargeOrderEntity rechargeOrder = rechargeOrderService.queryObject(id);

        return R.ok().put("rechargeOrder", rechargeOrder);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("rechargeorder:save")
    public R save(@RequestBody TbRechargeOrderEntity rechargeOrder) {
        rechargeOrderService.save(rechargeOrder);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("rechargeorder:update")
    public R update(@RequestBody TbRechargeOrderEntity rechargeOrder) {
        rechargeOrderService.update(rechargeOrder);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("rechargeorder:delete")
    public R delete(@RequestBody Integer[] ids) {
        rechargeOrderService.deleteBatch(ids);

        return R.ok();
    }

}
